package com.demo.controller;

import com.demo.service.DemoService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("demo")
public class DemoController {

    @Resource
    private DemoService demoService;


    /**
     * post方法 PostMapping
     * @return 返回类可自定义
     * */
    @PostMapping("postMethod")
    //@RequestMapping(value = "postMethod",method = RequestMethod.POST)
    public ResponseEntity<Object> demoPost(
            //@RequestBody 请求体
            @RequestParam(required = false,defaultValue = "0") int param1, //请求参
            HttpServletRequest request
    ){
        demoService.demo1();
        return ResponseEntity.accepted().body(param1);
    }

    /**
     * get方法 GetMapping
     * */
    @GetMapping("postMethod")
    public ResponseEntity<Object> demoGet(){
        demoService.demo1();
        return ResponseEntity.accepted().body(null);
    }

    /**
     * del方法 deleteMapping
     * */
    @DeleteMapping("deleteMethod")
    public ResponseEntity<Object> demoDel(){
        demoService.demo1();
        return ResponseEntity.accepted().body(null);
    }
}
